import React, { Component } from 'react';
import PropTypes from 'prop-types';

class TodoItem extends Component {
    constructor(props) {
        super(props);
        this.handleClick = this.handleClick.bind(this)
    }
    render() {
        const {content} = this.props
        return (
            <div onClick={this.handleClick}>
                {content}
            </div>
        )
    }
    // 要删除，就是修改父组件的list,调用父组件的方法，把index传过去
    handleClick() {
        const {deleteItem,index} = this.props;
        deleteItem(index)
    }
}

TodoItem.propTypes = {
    content: PropTypes.string,
    deleteItem:PropTypes.func,
    index:PropTypes.number
}

export default TodoItem